package net.cloudcodex.client.storyboard.player.view;

import net.cloudcodex.client.widgets.CharacterAvatar;
import net.cloudcodex.client.widgets.DecanterPanel;

import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.inject.Inject;

public class SceneViewImpl extends FlowPanel implements SceneView {
	private final Constant constant;

	private final FlowPanel header = new FlowPanel();
	private final DecanterPanel messageContainer = new DecanterPanel();


	@Inject
	public SceneViewImpl(Constant constant) {
		this.constant = constant;

		final Label label = new Label("Scene with:");
		label.addStyleName(this.constant.getHeaderCharacterStyle());
		this.header.add(label);

		this.add(this.header);
		this.add(this.messageContainer);
	}

	@Override
	public CharacterAvatar addCharacter(String name, String icon, Long id) {
		CharacterAvatar avatar = new CharacterAvatar();
		avatar.initComponent(icon, name);

		avatar.addStyleName(this.constant.getHeaderCharacterStyle());
		avatar.setId(id);
		this.header.add(avatar);
		return avatar ;
	}

	@Override
	public void insertMessage(MessageView message, int index) {
		this.messageContainer.insert(message, index);
	}

	@Override
	public void moveMessage(int fromIndex, int toIndex) {
		this.messageContainer.move(fromIndex, toIndex);
	}

	@Override
	public void removeMessage(MessageView message) {
		this.messageContainer.remove(message);
	}

}
